﻿<UserControl x:Class="Vtron.HipcConfigurationTools.CodecListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
    <UserControl.Resources>
        <!--<Style x:Key="PathMouseOverStyle" TargetType="{x:Type Path}">
            <Setter Property="Fill" Value="#FF77B6EB"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Fill" Value="#7F77B6EB"/>
                </Trigger>
            </Style.Triggers>
        </Style>-->
        <Style x:Key="itemstyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="SnapsToDevicePixels" Value="true"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Foreground" Value="#000000"/>

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border Name="Border" Padding="2" SnapsToDevicePixels="true"  CornerRadius="4" Margin="0,4,0,0">
                            <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                                <Setter Property="Background" TargetName="Border"  Value="#A5FFFFFF"></Setter>
                            </Trigger>
                            <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                                <Setter Property="Background" TargetName="Border"  Value="#01FFFFFF"></Setter>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background" TargetName="Border" Value="#99B4C6"/>
                                <Setter Property="Foreground" Value="#000000"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Background" TargetName="Border" Value="#c5d7e5"/>
                                <Setter Property="Foreground" Value="#000000"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="#000000"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <StackPanel>
        <ListView Name="CodecListListView" 
                  ItemsSource="{Binding CodecInfoes}" SelectedItem="{Binding Mode=TwoWay, Path=CurrentCodecItem}"
                  AlternationCount="2"
                  BorderThickness="0" Width="Auto"
                  IsSynchronizedWithCurrentItem="True" 
                  ItemContainerStyle="{StaticResource itemstyle}">
            <ListView.View>
                <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="编码器列表">
                    <!--<GridViewColumn Header="序号" DisplayMemberBinding="{Binding Path=Index}" Width="65"/>-->
                    <GridViewColumn Header="IP地址" DisplayMemberBinding="{Binding Path=Ip}" Width="85" />
                    <GridViewColumn Header="板子类型"  DisplayMemberBinding="{Binding Path=CodecType}" Width="85" />
                    <GridViewColumn Header="信号源类型"  DisplayMemberBinding="{Binding Path=SignalType}" Width="85" />
                    <GridViewColumn Header="操作" Width="65" >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button Command="{Binding DataContext.RemoveCodecCommand, RelativeSource={RelativeSource AncestorType={x:Type ListView}}}" CommandParameter="{Binding}" Template="{StaticResource RemoveXButtonTemplate}"  Cursor="Hand" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </StackPanel>
</UserControl>
